package com.byq.mm.application.cluster.client;

import com.byq.mm.abstractx.device.Device;
import com.byq.mm.abstractx.engine.CoreEnvironment;
import com.byq.mm.abstractx.protocol.Interaction;
import com.byq.mm.application.cluster.provider.ObdProvider;
import com.byq.mm.foundation.cluster.client.BasicClusterClient;
import com.byq.mm.foundation.cluster.datatype.AttributeValue;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;



public class ObdClient extends BasicClusterClient {
	Map<String, String> values = new HashMap<String, String>();
	public ObdClient(String cluster, Device device, CoreEnvironment e) {
		super(cluster, device, e);
		
	}
	public void request(String request){
		Interaction i = this.createRequest();
		i.command = ObdProvider.Define.ClientCommand.OBD_REQUEST;
		i.attributes.put("request", request);
		env.getExtensionManager().sendInteraction(i,
				getDevice().getTransportId());
	}
	
	@Override
	public boolean onReport(Interaction i) {
		if(i.command.equals(ObdProvider.Define.ServerCommand.OBD_RESPONSE)){
			values.put(i.attributes.get("request"), i.attributes.get("response"));
		}
		return true;
	}
	@Override
	protected Class<? extends AttributeValue> getAttributeType(String attributeName) {
		
		throw new RuntimeException("no attribute in this cluster!");
	}
	
	@Override
	protected void init() {
		
	}



}
